Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter items by can_contain L:, V:, M: (longest_side, volume, mass); affects AIM, inventory… #78519

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

Brambor
Copy link
Contributor

@Brambor Brambor commented Dec 12, 2024

Summary

Interface "Filter items by can_contain L:, V:, M: (longest_side, volume, mass); affects AIM, inventory…"

Purpose of change

Describe the solution

  • Similar to Crafting GUI: Filter recipes by what can fit into the result (longest_side, volume, mass) #78384 with key differences:
    • Store the fake items and their itype in the lambda capture, instead of static variable local to the file.
    • Failure cannot generate a popup with a helpful message. At least not always, so it never does. The reason is in AIM the filter is applied on each keystroke of L:122 cm and we cannot throw 6 popups at the player when they write :122 c.
      • Subject to change. It would be better if hinted.

Describe alternatives you've considered

  • Share the template code with Refactor filters in crafting GUI to use a template #78518. The use cases are different enough, so the template would be too complicated.
  • Fully implement displaying the helpful hint in every relevant menu.
  • Make AIM not live (update after each keystroke when writing a filter). And show a hint popup when the filter is finished and invalid.
  • Hook up to AIM and only show the helpful hint on an invalid filter after the player enters ENTER denoting "I am finished with the filter." Answering the question "Why doesn't it work?"
    • I didn't bother with this now, could be cool.
    • Should be implemented for all the other menus too.

Testing

Use the filters in

  • AIM
  • V List all items around the player
  • a Use item

Additional context

  • Without AIM cache filter function once #78480 this would be too slow in AIM.
  • This part could be implemented in item_controller as item_controller::get( const itype & ). It would be more efficient, this passes all items:
item_controller->find( [](
    const itype & i ) {
        return i.get_id() == STATIC( itype_id( "debug_item_search" ) );
    } )[0]

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) Info / User Interface Game - player communication, menus, etc. labels Dec 12, 2024
@Brambor Brambor force-pushed the inventory-filters-lvm branch from 78caec6 to 2e1d8d1 Compare December 12, 2024 20:19
@Brambor Brambor force-pushed the inventory-filters-lvm branch from 2e1d8d1 to 6ca0bee Compare December 12, 2024 20:20
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Dec 12, 2024
@Night-Pryanik Night-Pryanik merged commit 1205496 into CleverRaven:master Dec 13, 2024
25 checks passed
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Dec 13, 2024
@Brambor Brambor deleted the inventory-filters-lvm branch December 13, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter items with pockets by pocket's length, weight, volume
2 participants